extends "../meiyinci-2/meiyinci-2.gd"


func _extInit():
	._extInit()
	lv = 3             #等级的设置
	addSkill("每{cd}秒对护甲最低的敌人连开6枪，每枪造成[攻击50%]的炮击伤害", "快速射击", "meiyinci3", 8)
var p3 = 1
func _castCdSkill(id):
	._castCdSkill(id)
	if id == "meiyinci3":
		meiyinci3()
var skIndex = 0
func meiyinci3():
	var cha = getFirstCha(1, "sortByDef")
	if cha != null:
		skIndex += 1
		for i in range(6):
			if cha.isDeath:break
			azurHurtChara(cha, att.atk*0.5, sys.HurtType.WEAPON, sys.AtkType.GUN, "快速射击", false, p3)
		if skIndex >= 3 and lv == 4:
			skIndex = 0
			judge()

func judge():
	if upgraded == 2:
		dojudge()
		return
	addBuff(b_mainz.new(4))
	yield(reTimer(4), "timeout")

func dojudge():
	utils.createSkillTextEff("审判", position)
	var chas = getAllChas(1)
	chas.sort_custom(self, "sortByDistance")
	var dmg = att.atk * 3
	for i in range(5):
		if i >= chas.size():break
		for j in range(5):
			if chas[i].isDeath:continue
			azurHurtChara(chas[i], dmg, sys.HurtType.WEAPON, sys.AtkType.GUN, "审判")

func normalAtkChara(cha):
	if hasBuff("b_mainz") == null:
		.normalAtkChara(cha)

func _onBattleEnd():
	._onBattleEnd()
	skIndex = 0
	
class b_mainz:
	extends "../../../azurlane_ctrl/AzurBuff.gd"
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_mainz"
		att.defR = -3
		buffName = "蓄力"
		dispel = 3
	func _del():
		._del()
		masCha.dojudge()